<!DOCTYPE html>
<html>
<head>
	<title>String</title>
</head>
<body>
<script type="text/javascript">
	
	// 字符串相加
	console.log('abc' + null);
	console.log('abc' + undefined);
	console.log('abc' + true);
	console.log('abc' + false);
	console.log('abc' + 123);
	// 字符可以和任何关键字相加，结果都为字符串


	// 转换字符串
	// 1. toString()
	let num = 123;
	let bol = false;
	let nu = null;
	let und = undefined;
	console.log(num.toString());
	console.log(bol.toString());
	console.log(nu.toString());		// 出错
	console.log(und.toString());	// 出错
	// null、undefined 没有toString()方法

	// 2. String()
	console.log(String(nu));
	console.log(String(und));

</script>
</body>
</html>